from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QThread,pyqtSignal
import json
import os
__dir__ = os.path.dirname(os.path.abspath(__file__))
__config_dir__ = __dir__+'/config.json'
from pages.MainWindow import MainWindow
from pages.Setting import Setting

class Controller:
    # 初始化配置
    config = None
    OCR = None
    TRAN = None
    main = None
    setting = None

    def __init__(self):
        # 初始化
        self.config = self.initConfig()
        # 页面加载
        self.main = MainWindow(self)
        self.setting = Setting(self)
        # 首页导入，窗口最顶层显示
        self.main.show()
        self.main.activateWindow()

    def initConfig(self):
        with open(__config_dir__, 'rb') as f:
            params = json.load(f)
        f.close()
        return params

    def checkSetting(self):
        self.main.hide()
        self.setting.show()

    def showMain(self):
        self.main.showNormal()

    def sureArea(self):
        self.main.IS_HAVE_AREA = True

    def setMainHk(self, key):
        self.main.chanHK(key)
        

if __name__ == '__main__':
    app = QApplication([])
    con = Controller()
    app.exec_()
